﻿<MudDropContainer T="SimpleDropItem"
				  Items="_items" ItemsSelector="@((item,dropzone) => item.ZoneIdentifier == dropzone)"
				  Class="d-flex"
				  DraggingClass="my-special-dragging-class" ItemDraggingClass="my-special-item-dragging-class"
				  ItemDropped="ItemUpdated">
	<ChildContent>
		<MudDropZone OnlyZone="@HideItemsInFirstDropZone" T="SimpleDropItem" Identifier="Column 1" Class="first-drop-zone">
			<MudText Typo="Typo.h6" Class="mb-4">Drop Zone 1</MudText>
		</MudDropZone>
		<MudDropZone T="SimpleDropItem" Identifier="Column 2" Class="second-drop-zone"
					 DraggingClass="my-special-drop-zone-dragging-class" ItemDraggingClass="my-special-item-drop-zone-dragging-class">
			<MudText Typo="Typo.h6" Class="mb-4">Drop Zone 2</MudText>
		</MudDropZone>
	</ChildContent>
	<ItemRenderer>
		<MudText>@context.Name</MudText>
	</ItemRenderer>
</MudDropContainer>

@code {
    private readonly IEnumerable<SimpleDropItem> _items =
    [
        new("First Item", "Column 1"),
        new("Second Item", "Column 2"),
        new("Third Item", "Column 2")
    ];

	[Parameter]
    public bool HideItemsInFirstDropZone { get; set; } = true;

	private static void ItemUpdated(MudItemDropInfo<SimpleDropItem> dropItem)
    {
        if (dropItem.Item is null)
        {
            return;
        }

        dropItem.Item.ZoneIdentifier = dropItem.DropzoneIdentifier;
    }

    public class SimpleDropItem(string name, string zoneIdentifier)
    {
        public string Name { get; set; } = name;

        public string ZoneIdentifier { get; set; } = zoneIdentifier;
    }
}
